package conditionsAPI;

public abstract class ComposedDomainCondition extends DomainCondition{
	public boolean addPreCondition(DomainCondition domainCondition){
		Condition conditionToAdd = domainCondition.getCondition();
		return this.getComposedCondition().addPreCondition(conditionToAdd);
	}
	
	public boolean removePreCondition(DomainCondition domainCondition){
		Condition conditionToRemove = domainCondition.getCondition();
		return this.getComposedCondition().removePreCondition(conditionToRemove);
	}
	
	@Override
	public boolean checkConditionState(Object domainObject){
		return this.getComposedCondition().checkConditionState(domainObject);
	}
	
	/**
	 * Al resetear el estado de las hojas del arbol el estado de las condiciones
	 * compuestas se actualiza solo.
	 */
	@Override
	protected void resetState(){
	}
	
	protected Condition getCondition(){
		return getComposedCondition();
	}
	
	protected abstract ComposedCondition getComposedCondition();
}
